package com.example.accessingdatajpa.controller;

import com.example.accessingdatajpa.pojo.Role;
import com.example.accessingdatajpa.response.RestResponse;
import com.example.accessingdatajpa.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class RoleController {
    @Autowired
    final private IRoleService roleService;

    public RoleController(IRoleService roleService) {
        this.roleService = roleService;
    }

    //查询全部
    @GetMapping("/getAllRoles")
    public @ResponseBody RestResponse<List<Role>> findAllRoles(){
        return roleService.queryAllRoles();
    }

    //新增角色
    @PostMapping("/addRoles")
    public @ResponseBody RestResponse<String> addNewRoles(@RequestBody Role role){
        return roleService.addRoles(role);
    }
}
